package com.luckberry.murder.mapper;

import com.luckberry.murder.entity.good.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {

    @Select("select * from `order`")
    List<Order> getOrders();

    @Select("select * from `order` where uid = #{uid}")
    List<Order> getOrdersByUser(int uid);

    @Select("select * from `order` where oid = #{oid}")
    Order getOrder(int oid);

    @Insert("insert into `order`(uid, type, price, content, count, time) VALUES (#{uid}, #{type}, #{price}, #{content}, #{count}, #{time})")
    int addOrder(Order order);

    @Delete("delete `order` from `order` where oid = #{oid}")
    int deleteOrder(int oid);

    @Update("update `order` set uid = #{uid}, type = #{type}, price = #{price}, content = #{content}, count = #{count}, time = #{time} where oid = #{oid}")
    int editOrder(Order order);
}
